# -*- coding: iso-8859-1 -*-
#
#    This is part of Malvinas Argentinas Messenger
#
#    Malvinas Argentinas Messenger is free software; you can redistribute
#    it and/or modify it under the terms of the GNU General Public License
#    as published by the Free Software Foundation; either version 2 of the
#    License, or (at your option) any later version.
#
#    Malvinas Argentinas Messenger is distributed in the hope that it will be
#    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Malvinas Argentinas Messenger; if not, write to the Free 
#    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 
#    MA  02110-1301  USA

import option
import gettext
_ = gettext.gettext

class OptionsList:
	def __init__(self):
		self.list = []

	def appendOption(self, item):
		self.list.append(item)
	
	# Option list and index to list index
	def optToListIndex(self, list, index):
		count = -1
		for i in self.list:
			count += 1
			if i.list == list and i.index == index:
				break
		return count

	# Option name to list index
	def optToList(self, opt):
		list = -1
		for i in self.list:
			if opt in i.name:
				list = i.list
				break
		return list

	# Option name to option index
	def optToIndex(self, opt):
		list = -1
		for i in self.list:
			if opt in i.name:
				list = i.index
				break
		return list

	# Option name to list index
	def nametoIndex(self, name):
		count = -1
		for i in self.list:
			count += 1
			if name in i.name:
				break
		return count
	
	def buildList(self):
		new_option = option.Option(0, 0, _('Change status'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(0, 1, _('Change nick'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(0, 2, _('Insert emoticon'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(0, 3, 'LINE', 1, 1)
		self.appendOption(new_option)
		#new_option = option.Option(0, 4, _('Change configuration'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(0, 5, _('Files transfer'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(0, 6, _('Show logs'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(0, 7, _('Show lists'), 0, 0)
		#self.appendOption(new_option)
		new_option = option.Option(0, 4, _('Handle contacts/groups'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(0, 5, 'LINE', 1, 1)
		self.appendOption(new_option)
		new_option = option.Option(0, 6, _('Quit'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 0, 'NLN - ' + _('Online'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 1, 'BRB - ' + _('Be Right Back'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 2, 'LUN - ' + _('Out to lunch'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 3, 'PHN - ' + _('At the phone'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 4, 'BSY - ' + _('Busy'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 5, 'AWY - ' + _('Away'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 6, 'IDL - ' + _('Idle'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(1, 7, 'HDN - ' + _('Hidden'), 1, 0)
		self.appendOption(new_option)
		#new_option = option.Option(7, 0, _('Show events log'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(7, 1, _('Show conversation log'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(8, 0, _('Show allowed list'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(8, 1, _('Show reverse list'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(8, 2, _('Show blocked list'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(8, 3, _('Show difference list'), 0, 0)
		#self.appendOption(new_option)
		new_option = option.Option(5, 0, _('Show contact info'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 1, 'LINE', 1, 1)
		self.appendOption(new_option)
		new_option = option.Option(5, 2, _('Add contact'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 3, _('Rename contact'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 4, _('Block / Unblock contact'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 5, _('Delete contact'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 6, _('Move contact to group'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 7, 'LINE', 1, 1)
		self.appendOption(new_option)
		new_option = option.Option(5, 8, _('Add group'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 9, _('Rename group'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 10, _('Block / Unblock group'), 1, 0)
		self.appendOption(new_option)
		new_option = option.Option(5, 11, _('Delete group'), 1, 0)
		self.appendOption(new_option)
		#new_option = option.Option(6, 0, _('Send file'), 0, 0)
		#self.appendOption(new_option)
		#new_option = option.Option(6, 1, _('Transfers statuses'), 0, 0)
		#self.appendOption(new_option)

	def size(self, num_list):
		count = 0
		for i in self.list:
			if i.list == num_list:
				count += 1
		return count
